from SimpleXMLRPCServer import SimpleXMLRPCServer
import time
import thread

class StoppableXMLRPCServer(SimpleXMLRPCServer):
	#allow_reuse_address = True
	#stop = False

	def test(self, messge):
		print message

	def serve_forever(self):
		self.stop = False
		while not self.stop:
			self.handle_request()
			print "handle_request"

		print "stop .."

	def stopQ(self):
		self.stop = True
		self.server_close()

def stop(s,delay):
	time.sleep(delay)
	s.stop = True
	
if __name__ == "__main__" :
	s = StoppableXMLRPCServer(("localhost", 8877))

	print "start service @localhost 8877 not forever"

	#thread.start_new_thread(stop,(s,5,))
	s.serve_forever()
	

